<?
/* 
Configuration Manager v1.0
Made by: Are Haugsdal 24.11.2004 
This is file to fill option boxes and other variables with data.
*/

function getLangUser($aType=1)
{
	$dir = opendir("language_src/");
	
	while ($file = readdir($dir))
  	{
  		$lSkipLang=0;
  	
		if ($file <> "." AND $file <> ".." AND !ereg("user",$file))
        {
        	if ($aType==1)
        	{
        		if (ereg("adm_",$file))
        			$lSkipLang=1;	
        	}
        	elseif ($aType==2)
        	{
        		if (!ereg("adm_",$file))
        			$lSkipLang=1;	
        	}
        		
        	if (!$lSkipLang)
        	{
		  		$file = substr($file,0,3); 
		  		$array[] = $file . "," . $file;
        	}
		}
  	}
  	closedir($dir);
	return $array;
}

function getLangAdmin($aType=2)
{
	$dir = opendir("language_src/");
	
	while ($file = readdir($dir))
  	{
  		$lSkipLang=0;
  		
		if ($file <> "." AND $file <> ".." AND !ereg("user",$file))
        {
        	
        	if ($aType==1)
        	{
        		if (ereg("adm_",$file))
        			$lSkipLang=1;	
        	}
        	elseif ($aType==2)
        	{
        		if (!ereg("adm_",$file))
        			$lSkipLang=1;	
        	}
        	
        	if (!$lSkipLang)
        	{
		  		$file = substr($file,4,3); 
		  		$array[] = $file . "," . $file;
        	}
		}
  	}
  	closedir($dir);
	return $array;
}

function getTemplateSets()
{
	$dir = opendir("../admin/");
	
	while ($file = readdir($dir))
  	{
  		
		if ($file <> "." AND $file <> ".." AND eregi("templates",$file))
        {
		  	$file = eregi_replace("_src","",$file); 
		  	$array[] = $file . "," . $file;
		}
  	}
  	closedir($dir);
	return $array;
}

function getURL()
{
	$tryurl.=$_SERVER['SERVER_NAME'] . "" . $_SERVER['SCRIPT_NAME']; 
	$tryurl=eregi_replace("www.localhost","localhost",$tryurl);
	$tryurl=eregi_replace("/admin/set.php","",$tryurl);
	$tryurl=eregi_replace("/install.php","",$tryurl);
	return $tryurl;
}

function getPATH()
{
	$set_path = getcwd();
	$set_path=ereg_replace("admin","",$set_path);
	return $set_path;
}

function getDeleteAfterXDays()
{
	
	$string="";
  for ($i=20; $i<200; $i++)
  	$array[].="$i,$i";
  
  return $array;
}
function getRef()
{
	$lRef=strtolower($_SERVER['SERVER_NAME']);
	$lRef=eregi_replace("www","",$lRef);
  	return $lRef;
}

function getPaymentVendors()
{
	global $set_table_gw;
	$lSql="select gw_id,gw_name from $set_table_gw"; // Get GW
	$lRes=q($lSql);
	$i=0;
	while ($lRow=mysql_fetch_array($lRes))
	{
		$lVendor[$i]["id"]=$lRow["gw_id"];
		$lVendor[$i]["name"]=$lRow["gw_name"];
		$i++;
		
	}
	
	return $lVendor;
	
}
?>